<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
    public function login(){
        return view('home.index.login');
    }
    public function loginer(Request $request){
//        dd($_POST);die;
        $status = Auth::attempt([
           'email'=>$request->input('email'),
            'password'=>$request->input('password'),
        ]);

        if($status && Auth::user()->status){
            session()->flash('success','登录成功');
            return redirect('/index');
        }else{
            session()->flash('danger','登录失败或账号未激活');
            return redirect()->route('login');die;
        }
    }
    public function loginOut(){
        Auth::logout();
        session()->flash('success','退出成功');
        return redirect()->route('login');
    }
}
